home *** CD-ROM | disk | FTP | other *** search
/ ASP Advantage 1993 / The Association of Shareware Professionals Advantage CD-ROM 1993.iso / files / commions / ca29_1 / ca29_3.exe / LEARN.SRC < prev    next >
Text File  |  1992-09-21  |  50KB  |  1,811 lines

  1.    SET TTHRU OFF        ; Make first to allow typeahead
  2.    S19 = "Learn   ver 1.0     " ; 20 chars long
  3. ; ----- Learn: Learn mode shell for COM-AND
  4. ;
  5. ;    R.McG; 8/89, Chicago
  6. ; ----------------------------------------------------------------
  7. ; Usages:
  8. ;      S19 -----> Legend line
  9. ;      S18 -----> Load-time drive:subdirectory (for exit)
  10. ;      S17 -----> Load-time download d:subdir (for exit)
  11. ;      S16 -----> Output file name
  12. ;      S12 -----> Text before last line displayed to screen
  13. ;      S11 -----> Last line displayed to screen
  14. ;      S10 -----> Current output buffer
  15. ;
  16. ;      N99 -----> Number of lines on screen
  17. ;      N96 -----> Current receive area cursor
  18. ;      N95 -----> Current receive area cursor
  19. ;      N94 -----> Current Kbd area cursor
  20. ;      N93 -----> Current Kbd area cursor
  21. ;      N92 -----> Saved cursor on entry
  22. ;      N91 -----> Saved cursor on entry
  23. ;      N90 -----> Current output buffer index
  24. ;
  25. ;      FLAG(0) -> ESCAPE has been hit if ON
  26. ;      FLAG(1) -> Off: no printer    on: Printer in use
  27. ;      FLAG(2) -> Off: log not used    on: Log was used
  28. ;      FLAG(8) -> Off: learning,    on: learning suspended
  29. ;      FLAG(9) -> Off: in line mode, on: in character mode
  30. ; -----------------------------------------------------------------------
  31. ;
  32. ;    Initialization
  33. ;
  34.    CURSOR N91,N92        ; Read current cursor
  35.    LEGEND S19            ; Set initial legend
  36.    SUBDIR S18            ; Read current subdir
  37.    DLDIR S17            ; Read current download subdir
  38.    SSIZE N99            ; Get current screen size
  39.    SAVE 0,0,N99-2,79        ; Save original screen
  40.    ON ESCAPE GOSUB ESCAPE    ; Escape action
  41.    SET FLAG(1) OFF        ; Set printer on/off flag
  42.    IF STRCMP "_PRIN" "ON"       ; .. as we only turn printer on
  43.       SET FLAG(1) ON        ; .. during receive portion
  44.       PRINTER OFF        ; Turn printer off unconditionally
  45.       ENDIF
  46. ;
  47. ;    Ask for an output file name
  48. ;
  49. Get_Output:
  50.    S1 = "Enter a file name to be output:"
  51.    GOSUB Ask_File        ; Ask for an output file
  52.    IF NOT SUCCESS EXIT        ; If ESC'd then stop
  53.    S16 = S0            ; Save fname
  54. ;
  55. ;    Test for file existing
  56. ;
  57.    IF ISFILE S16        ; If file exists
  58.       S0 = S16 *" already exists.  Overwrite it? Y/N (cr=no)"
  59.       GOSUB Ask_YN
  60.       IF NOT SUCCESS GOTO Get_Output
  61.       ENDIF
  62. ;
  63. ;    Open the output file, no append
  64. ;
  65.    FOPENO S16 TEXT        ; Open output file
  66.    IF NOT SUCCESS
  67.       S0 = "Error opening output file: "*S16
  68.       GOSUB Error        ; Report
  69.       GOTO Get_output
  70.       ENDIF
  71. ;
  72. ;    Perform other initialization
  73. ;
  74.    GOSUB Initial        ; Save initial settings
  75.    SET CHAT OFF         ; Turn off chat
  76.    GOTO START            ; And continue
  77. ;
  78. ; ----- Subroutine: Escape - Set a flag for mainline loop
  79. ;
  80. Escape:
  81.    SET FLAG(0) ON        ; Flag fact
  82.    RETURN            ; And continue
  83. ;
  84. ;------ Subroutine: Terminate the all LEARN script activity
  85. ;
  86. End_Learn:
  87.    DWINDOW CLEAR        ; Clear display window
  88.    IF FLAG(2) and STRCMP "_LOGG" "ON "
  89.       WRITE "LOG CLOSE!"        ; FInish logging if on and turned on within
  90.       LOG CLOSE
  91.       ENDIF
  92.    WRITE "^Z" 2                 ; Terminate w/EOF
  93.    FCLOSEO            ; Close output file
  94.    SET DLDIR S17        ; Reset DLDIR  to load time
  95.    CHDIR S18            ; Reset default subdir to load time
  96.    RESTORE            ; Restore screen
  97.    LOCATE N91,N92        ; Restore cursor
  98.    IF FLAG(1)            ; Set printer according to current state
  99.       PRINTER ON
  100.    ELSE
  101.       PRINTER OFF
  102.       ENDIF
  103.    RETURN            ; Rtn to caller
  104. ;
  105. ;------ Subroutine: Ask if Exit to be taken
  106. ;
  107. Exit:
  108.    S0 = "Do you wish to terminate LEARN?  Enter Y to terminate."
  109.    GOSUB Ask_YN
  110.    IF SUCCESS            ; IF answer is 'y'
  111.       GOSUB End_Learn        ; Terminate
  112.       EXIT            ; And stop script
  113.       ENDIF
  114.    SET FLAG(0) OFF        ; Clear ESC flag
  115.    RETURN            ; And continue
  116. ;
  117. ; ----- Main-line: Draw the screen, and begin loop
  118. ;
  119. Start:
  120.    N90 = 0            ; Initialize buffer index
  121.    S11 = ""                     ; Init last line received
  122.    S12 = ""                     ; Init next ot last line received
  123.    SET FLAG(0) OFF        ; Init ESC hit flag
  124.    SET FLAG(9) OFF        ; Init to line mode
  125.    SET FLAG(8) OFF        ; Init to not held
  126.    GOSUB Screen         ; Draw screen
  127.    LOCATE 1,1            ; Set cursor
  128.    DWINDOW N99-12,2 N99-12 77    ; Set kbd scrolling region
  129.    GOTO Main
  130. ;
  131. ;    Write a line (in S0, less CRLF) to the output file
  132. ;
  133. Output:
  134.    WRITE S0            ; Write to file
  135.    WRITE "!"                    ; Add a crlf
  136. ;
  137. ;    Display received text, and wait for a keypress
  138. ;
  139. Main:
  140.    LOCATE N93,N94        ; Set kbd cursor
  141.    IF FLAG(0) GOSUB Exit    ; If ESC pressed, ask if to exit
  142.    IF NOT HITKEY        ; If nothig on kbd
  143.       IF RECEIVE GOSUB Receive    ; Allow incoming text to be displayed
  144.       GOTO Main
  145.       ENDIF
  146. ;
  147. ;    We have a keypress pending
  148. ;
  149.    KEYGET S1            ; Read a single key
  150.    LENG S1 N0            ; Compute length of KEYGET
  151.    SWITCH N0
  152.       CASE 1            ; length = 1
  153.      GOTO ASCII
  154.       ENDCASE
  155.       CASE 2            ; length = 2
  156.      GOTO CONTROL
  157.       ENDCASE
  158.       CASE 4            ; length = 4
  159.      GOTO FUNCTION
  160.       ENDCASE
  161.    ENDSWITCH
  162.    GOTO Main            ; And continue
  163. ;
  164. ;    Update the keyboard display
  165. ;
  166. KbdDisp:
  167.    IF GT N90 0
  168.       S0 = S10(0:n90-1)     ; COpy current buffer
  169.       PRESERVE S0        ; Make displayable
  170.       ATSAY N99-12,2 (Default) S0 *"  "
  171.       ENDIF
  172.    N94=N90+2            ; Set new col #
  173.    GOTO Main
  174. ;
  175. ; ----- Subroutine: Handle receipt of text
  176. ;
  177. Receive:
  178.    DWINDOW 1, 0,(N99-14),79    ; Set rcv scrolling region
  179.    IF FLAG(1) PRINTER ON    ; Turn on printer while reading comm
  180.    LOCATE N95,N96        ; Set rcv cursor
  181.    S12 = S11            ; Save previous line read
  182.    RGET S11 80 1        ; Read new text, max wait 1 sec
  183.    CURSOR N95,N96        ; Read new rcv area cursor
  184.    IF FLAG(1) PRINTER OFF    ; Turn off printer now
  185.    DWINDOW N99-12,2 N99-12,77    ; Set kbd scrolling region
  186.    RETURN
  187. ;
  188. ;    ASCII char entered: length in N0 is 1
  189. ;
  190. ASCII:
  191.    IF FLAG(8)            ; If learn held
  192.       PRESERVE S1        ; ..
  193.       TRANSMIT S1        ; Send the char
  194.       GOTO Main         ; .. and no more
  195.       ENDIF
  196.    ;
  197.    ;    Catch buffer overflow (limit kbd buffer to 60 chars)
  198.    ;
  199.    IF GT (N90+2) 60
  200.       SOUND 100,100
  201.       GOTO Main
  202.       ENDIF
  203.    ;
  204.    ;    Buffer the char (preserving for TRANSMIT)
  205.    ;
  206.    S10(N90:N90) = S1        ; Buffer keystroke
  207.    INC N90
  208.    IF STRCMP S1 "!" or STRCMP S1 "^"
  209.       S10(N90:N90) = S1     ; DOuble special chars to PRESERVE for TRANSMIT
  210.       INC N90
  211.       ENDIF
  212.    ;
  213.    ;    If CHAR mode, send immediate
  214.    ;
  215.    IF FLAG(9) GOTO Transmit    ; If char mode transmit immediately
  216.    GOTO KbdDisp         ; Update kbd display
  217. ;
  218. ;    Handle control chars: length in N0 is 2
  219. ;
  220. Control:
  221.    S0 = "0x"*S1                 ; Make hex form of #
  222.    N0 = S0            ; If ctl char (e.g. 0d for c/r)
  223.    N0 = N0+64            ; Convert to ASCII @,A,B,...
  224.    S0 = "^"                     ; Store delimiter
  225.    ITOC N0 S0(1:1)        ; Store char being ctl'd
  226.    ;
  227.    ;    Simply xmit if LEARN HELD
  228.    ;
  229.    IF FLAG(8)            ; If learn held
  230.       TRANSMIT S0        ; Send the char
  231.       GOTO Main         ; .. and no more
  232.       ENDIF
  233.    ;
  234.    ;    Catch special control chars
  235.    ;
  236.    IF (NOT FLAG(9)) and STRCMP S1 "08" ; Catch backspace here
  237.       GOTO Backspace               ; .. in line mode
  238.       ENDIF
  239.    IF STRCMP S1 "0D"            ; Catch c/rs
  240.       GOTO RETURN        ; .. in either line or char mode
  241.       ENDIF
  242.    IF GT (N90+2) 60        ; Handle buffer overflow here
  243.       SOUND 100,100
  244.       GOTO Main
  245.       ENDIF
  246.    ;
  247.    ;    Buffer the remainder as "^" chars
  248.    ;
  249.    S10(N90:N90+1) = S0(0:1)    ; Store delimiter
  250.    N90 = N90+2
  251.    IF FLAG(9) GOTO Transmit    ; If char mode transmit directly
  252.    GOTO KbdDisp         ; Update kbd display
  253. ;
  254. ;    Backspace entered
  255. ;
  256. Backspace:
  257.    IF ZERO N90
  258.       GOTO KbdDisp
  259.       ENDIF
  260.    DEC N90
  261.    IF STRCMP S10(N90-1:N90-1) "^" or STRCMP S10(N90-1:N90) "!!"
  262.       DEC N90
  263.       ENDIF
  264.    GOTO KbdDisp         ; Update kbd display
  265. ;
  266. ;    Carriage return entered
  267. ;
  268. Return:
  269.    IF NOT ZERO N90
  270.       S10 = S10(0:N90-1)*"!"
  271.    ELSE
  272.       S10 = "!"
  273.       ENDIF
  274.    N90 = N90+1
  275. ;
  276. ;    Execute the current buffer
  277. ;
  278. Transmit:
  279.    GOSUB Waitfor        ; Emit a WAITFOR
  280.    ;
  281.    ;    Now, emit a TRANSMIT statement
  282.    ;
  283.    WRITE "TRANSMIT `""          ; Write TRANSMIT statement
  284.    IF STRCMP S10(N90-1:N90-1) "!!"
  285.       WRITE S10 N90-1        ; Write string to be xmitted less final c/r
  286.       WRITE "!!" 2              ; .. adding c/r after conversion
  287.    ELSE
  288.       WRITE S10 N90        ; Write string as-is
  289.       ENDIF
  290.    WRITE "`"!"                  ; .. finish the quoted string, and add a c/r
  291.    ;
  292.    ;    Perform the TRANSMIT and cleanup
  293.    ;
  294.    TRANSMIT S10(0:N90-1)
  295.    N90 = 0            ; Zero index to kbd buffer
  296.    CLEAR (default)        ; Clear kbd scrolling region
  297.    N94 = 2            ; Set cursor col
  298.    GOTO Main
  299. ;
  300. ; ----- Subroutine: Emit a WAITFOR
  301. ;
  302. Waitfor:
  303.    LJ S11            ; Left justify last text rcvd
  304.    S11 = S11&""                 ; Trim trailing spaces
  305.    LENGTH S11 N1        ; Length of last text rcvd
  306.    IF NOT ZERO N1        ; If a prompt (non null) was received
  307.       S0 = S11            ; Replicate
  308.       GOTO EmitWait        ; And emit a WAITFOR
  309.       ENDIF
  310.    ;
  311.    ;    Nothing received last... look at previous receipt
  312.    ;
  313.    LJ S12            ; Left justify
  314.    S12 = S12&""                 ; Trim trailing spaces
  315.    LENGTH S12 N1        ; length of text received prior to last
  316.    IF NOT ZERO N1        ; If a prompt (non null) was received
  317.       S0 = S12            ; Replicate
  318.       GOTO EmitWait        ; And emit a WAITFOR
  319.       ENDIF
  320.    ;
  321.    ;    Last 2 lines received were empty.
  322.    ;
  323.    WRITE ";!"                   ; Write a comment line
  324.    WRITE "; WAITFOR may be needed here!"
  325.    WRITE ";!"                   ; Write a comment line
  326.    RETURN
  327.    ;
  328.    ;    Emit a WAITFOR using the value in S0
  329.    ;
  330. EmitWait:
  331.    PRESERVE S0            ; Save carets/bangs
  332.    LENGTH S0 N1         ; Compute new length
  333.    WRITE "WAITFOR `""           ; Write WAITFOR
  334.    WRITE S0            ; Write string to be awaited
  335.    WRITE "`"!"                  ; .. finish the quoted string, and add a c/r
  336.    WRITE ";*IF NOT WAITFOR GOTO ...!"
  337.    S11 = ""                     ; Clear last receipt
  338.    S12 = ""                     ; ..
  339.    RETURN
  340. ;
  341. ;    Function key entered
  342. ;
  343. Function:
  344.    IF FLAG(8) and NOT STRCMP S1 "4000"
  345.       SOUND 100,100        ; Disallow if LEARN HELD
  346.       GOTO Main         ; .. and not the HOLD key
  347.       ENDIF
  348.    ;
  349.    ;    Interpret the char
  350.    ;
  351.    SWITCH S1
  352.       CASE "2E00"               ; Alt-C
  353.      GOTO Clear
  354.       ENDCASE
  355.       CASE "1200"               ; Alt-E
  356.      GOTO Echo
  357.       ENDCASE
  358.       CASE "2C00"               ; Alt-Z
  359.      GOTO Mask
  360.       ENDCASE
  361.       CASE "2600"               ; Alt-L
  362.      GOTO ScrSize
  363.       ENDCASE
  364.       CASE "2300"               ; Alt-H
  365.      GOTO Hangup
  366.       ENDCASE
  367.       CASE "2000"               ; Alt-D
  368.      GOTO Dial
  369.       ENDCASE
  370.       CASE "1900"               ; Alt-P
  371.      GOTO Parms
  372.       ENDCASE
  373.       CASE "3100"               ; Alt-N
  374.      GOTO Encrypt
  375.       ENDCASE
  376.       CASE "2200"               ; Alt-G
  377.      GOTO Blnkln
  378.       ENDCASE
  379.       CASE "1000"               ; Alt-Q
  380.      GOTO CRLF
  381.       ENDCASE
  382.  
  383.       CASE "7500"               ; Ctl-End
  384.      GOTO Break
  385.       ENDCASE
  386.       CASE "7200"               ; Ctl-PrtSc
  387.      GOTO Printer
  388.       ENDCASE
  389.       CASE "4900"               ; PgUp
  390.      GOTO Upload
  391.       ENDCASE
  392.       CASE "5100"               ; PgDn
  393.      GOTO Download
  394.       ENDCASE
  395.  
  396.       CASE "7800"               ; Alt-1
  397.      GOTO Alt_1
  398.       ENDCASE
  399.       CASE "7900"               ; Alt-2
  400.      GOTO Alt_2
  401.       ENDCASE
  402.       CASE "7A00"               ; Alt-3
  403.      GOTO Alt_3
  404.       ENDCASE
  405.       CASE "7B00"               ; Alt-4
  406.      GOTO Alt_4
  407.       ENDCASE
  408.       CASE "7C00"               ; Alt-5
  409.      GOTO Alt_5
  410.       ENDCASE
  411.       CASE "7D00"               ; Alt-6
  412.      GOTO Alt_6
  413.       ENDCASE
  414.       CASE "7E00"               ; Alt-7
  415.      GOTO Alt_7
  416.       ENDCASE
  417.       CASE "7F00"               ; Alt-8
  418.      GOTO Alt_8
  419.       ENDCASE
  420.       CASE "8000"               ; Alt-9
  421.      GOTO Alt_9
  422.       ENDCASE
  423.       CASE "8100"               ; Alt-0
  424.      GOTO Alt_0
  425.       ENDCASE
  426.  
  427.       CASE "3B00"               ; F1
  428.      GOTO Accessry
  429.       ENDCASE
  430.       CASE "3C00"               ; F2
  431.      GOTO Script
  432.       ENDCASE
  433.       CASE "3D00"               ; F3
  434.      GOTO Chdir
  435.       ENDCASE
  436.       CASE "3E00"               ; F4
  437.      GOTO DlDir
  438.       ENDCASE
  439.       CASE "3F00"               ; F5
  440.      GOTO LineChar
  441.       ENDCASE
  442.       CASE "4000"               ; F6
  443.      GOTO Hold
  444.       ENDCASE
  445.       CASE "4100"               ; F7
  446.      GOTO Log
  447.       ENDCASE
  448.       CASE "4300"               ; F9
  449.      GOTO LogHold
  450.       ENDCASE
  451.       CASE "4400"               ; F10
  452.      GOSUB Help        ; Note uncharacteristic GOSUB
  453.       ENDCASE
  454.       CASE "7100"               ; Alt-F10
  455.      GOTO Shell
  456.       ENDCASE
  457.       ;
  458.       ; Other keypresses are unrecognized
  459.       ;
  460.       DEFAULT
  461.      SOUND 100,100        ; Signal error
  462.       ENDCASE
  463.    ENDSWITCH
  464.    GOTO Main            ; And continue
  465. ;
  466. ;    Shell to DOS (for convenience only. SHELL is not written
  467. ;    .. to the learned script
  468. ;
  469. SHELL:
  470.    S16 = "_OFILE"               ; Save output fname
  471.    FCLOSEO            ; Close output file
  472.    DWINDOW Clear        ; Clear for implicit save
  473.    SHELL            ; Shell to DOS
  474.    DWINDOW N99-12,2 N99-12 77    ; ReSet kbd scrolling region
  475.    LEGEND S19            ; ReSet legend
  476.    FOPENO S16 TEXT APPEND    ; Allow edits during shell
  477.    GOTO Main
  478. ;
  479. ;    Clear the screen
  480. ;
  481. Clear:
  482.    DWINDOW 1, 0,(N99-14),79    ; Set rcv scrolling region
  483.    CLEAR (default)        ; Perform the clear function
  484.    CURSOR N95,N96        ; Set new cursor
  485.    DWINDOW N99-12,2 N99-12,77    ; Set kbd scrolling region
  486.    LOCATE N93,N94        ; Set kbd cursor
  487.    S0 = "CLEAR"                 ; Set-up the line to add to output
  488.    GOTO Output            ; Set-up the line to add to output
  489. ;
  490. ;    Toggle echo
  491. ;
  492. Echo:
  493.    S0 = "SET DUPLEX HALF"       ; Default as if full
  494.    IF STRCMP "_DUPL" "HALF"     ; Test current setting
  495.       S0 = "SET DUPLEX FULL"    ; Set-up cmd and output
  496.       ENDIF
  497.    PERFORM S0            ; Execute instruction in S0
  498.    GOSUB StatusLine
  499.    GOTO Output            ; Set-up the line to add to output
  500. ;
  501. ;    Toggle mask
  502. ;
  503. Mask:
  504.    S0 = "SET MASK ON"           ; Default as if off
  505.    IF STRCMP "_MASK" "ON "      ; Test current setting
  506.       S0 = "SET MASK OFF"       ; Set-up cmd and output
  507.       ENDIF
  508.    PERFORM S0            ; Execute instruction in S0
  509.    GOSUB StatusLine
  510.    GOTO Output            ; Set-up the line to add to output
  511. ;
  512. ;    Toggle screen size
  513. ;
  514. ScrSize:
  515.    S0 = "SET 43"
  516.    IF GT "_SSIZ" 25
  517.       S0 = "SET 25"
  518.       ENDIF
  519.    PERFORM S0            ; Execute instruction in S0
  520.    SSIZE N99            ; Get current screen size
  521.    GOSUB Screen         ; Redraw the screen
  522.    GOTO Output            ; Set-up the line to add to output
  523. ;
  524. ;    Send a macro
  525. ;
  526. Alt_0:
  527.    S0 = "MACRO 0"
  528.    GOTO Send_Macro        ; Set-up the line to add to output
  529. ;
  530. ;    Send a macro
  531. ;
  532. Alt_1:
  533.    S0 = "MACRO 1"
  534.    GOTO Send_Macro        ; Set-up the line to add to output
  535. ;
  536. ;    Send a macro
  537. ;
  538. Alt_2:
  539.    S0 = "MACRO 2"
  540.    GOTO Send_Macro        ; Set-up the line to add to output
  541. ;
  542. ;    Send a macro
  543. ;
  544. Alt_3:
  545.    S0 = "MACRO 3"
  546.    GOTO Send_Macro        ; Set-up the line to add to output
  547. ;
  548. ;    Send a macro
  549. ;
  550. Alt_4:
  551.    S0 = "MACRO 4"
  552.    GOTO Send_Macro        ; Set-up the line to add to output
  553. ;
  554. ;    Send a macro
  555. ;
  556. Alt_5:
  557.    S0 = "MACRO 5"
  558.    GOTO Send_Macro        ; Set-up the line to add to output
  559. ;
  560. ;    Send a macro
  561. ;
  562. Alt_6:
  563.    S0 = "MACRO 6"
  564.    GOTO Send_Macro        ; Set-up the line to add to output
  565. ;
  566. ;    Send a macro
  567. ;
  568. Alt_7:
  569.    S0 = "MACRO 7"
  570.    GOTO Send_Macro        ; Set-up the line to add to output
  571. ;
  572. ;    Send a macro
  573. ;
  574. Alt_8:
  575.    S0 = "MACRO 8"
  576.    GOTO Send_Macro        ; Set-up the line to add to output
  577. ;
  578. ;    Send a macro
  579. ;
  580. Alt_9:
  581.    S0 = "MACRO 9"
  582. ;
  583. ;    Finally, for all the above, send it
  584. ;
  585. Send_Macro:
  586.    PERFORM S0            ; Execute instruction in S0
  587.    GOTO Output            ; Set-up the line to add to output
  588. ;
  589. ;    Hangup
  590. ;
  591. Hangup:
  592.    GOSUB Waitfor        ; Emit waitfor
  593.    S0 = "HANGUP"
  594.    PERFORM S0            ; Execute instruction in S0
  595.    GOTO Output            ; Set-up the line to add to output
  596. ;
  597. ;    Send a break
  598. ;
  599. Break:
  600.    GOSUB Waitfor        ; Emit waitfor
  601.    S0 = "BREAK"
  602.    PERFORM S0            ; Execute instruction in S0
  603.    GOTO Output            ; Set-up the line to add to output
  604. ;
  605. ;    Toggle printer
  606. ;
  607. Printer:
  608.    IF FLAG(1)            ; Test flagged state
  609.       S0 = "PRINTER OFF"        ; .. If set printer is ON during rcv
  610.       SET FLAG(1) OFF
  611.    ELSE             ; Else its off now
  612.       S0 = "PRINTER ON"
  613.       SET FLAG(1) ON
  614.       ENDIF
  615.    WRITE S0*"!"                 ; LOG instruction in S0
  616.    GOSUB StatusLine
  617.    GOTO Main            ; Set-up the line to add to output
  618. ;
  619. ;    Toggle line/char mode
  620. ;
  621. LineChar:
  622.    IF FLAG(9)
  623.       SET FLAG(9) OFF
  624.    ELSE
  625.       SET FLAG(9) ON
  626.       ENDIF
  627.    GOSUB StatusLine
  628.    GOTO Main
  629. ;
  630. ;    Toggle learn hold
  631. ;
  632. Hold:
  633.    IF FLAG(8)
  634.       SET FLAG(8) OFF
  635.    ELSE
  636.       SET FLAG(8) ON
  637.       ENDIF
  638.    GOSUB StatusLine        ; Update status line
  639.    GOTO Main
  640. ;
  641. ; ----- Subroutine:  Upload current file
  642. ;
  643. UpLoad:
  644.    GOSUB Ask_Method
  645.    S1 = "/NONAME/"              ; Make file name null
  646.    SWITCH S0
  647.       CASE "_NULL"              ; No entry
  648.     GOTO Main        ; No action
  649.       ENDCASE            ; .. no action
  650.       CASE "0"                  ; ZMODEM
  651.      GOSUB Ask_Name     ; Ask for fname in S1
  652.      S0 = "SENDFILE ZMODEM S1"
  653.       ENDCASE
  654.       CASE "1"                  ; WXMODEM
  655.      GOSUB Ask_Name     ; Ask for fname in S1
  656.      S0 = "SENDFILE WXMODEM S1"
  657.       ENDCASE
  658.       CASE "2"                  ; XMODEM
  659.      GOSUB Ask_Name     ; Ask for fname in S1
  660.      S0 = "SENDFILE XMODEM S1"
  661.       ENDCASE
  662.       CASE "3"                  ; ASCII
  663.      GOSUB Ask_Name     ; Ask for fname in S1
  664.      S0 = "SENDFILE ASCII S1"
  665.       ENDCASE
  666.       CASE "4"                  ; YMODEM/XMODEM1K
  667.      GOSUB Ask_Name     ; Ask for fname in S1
  668.      S0 = "SENDFILE YMODEM S1"
  669.       ENDCASE
  670.       CASE "5"                  ; CISB
  671.      S0 = "SENDFILE CISB"
  672.       ENDCASE
  673.       CASE "6"                  ; QuickB
  674.      S0 = "SENDFILE QuickB"
  675.       ENDCASE
  676.       CASE "7"                  ; KERMIT
  677.      GOSUB Ask_Name     ; Ask for fname in S1
  678.      S0 = "SENDFILE KERMIT S1"
  679.       ENDCASE
  680.       CASE "8"                  ; Batch YMODEM
  681.      GOSUB Ask_Name     ; Ask for fname in S1
  682.      S0 = "SENDFILE BYMODEM S1"
  683.       ENDCASE
  684.       CASE "9"                  ; Batch YMODEM-G
  685.      GOSUB Ask_Name     ; Ask for fname in S1
  686.      S0 = "SENDFILE BYMOG S1"
  687.       ENDCASE
  688.  
  689.       DEFAULT
  690.     SOUND 100,100
  691.     GOTO Main        ; No action
  692.       ENDCASE
  693.    ENDSWITCH
  694. ;
  695. ;    If we have a valid file name, perform it
  696. ;
  697. Transfer:
  698.    IF NULL S1 GOTO Main     ; Catch failed Ask_Name
  699.    PERFORM S0
  700.    IF NOT STRCMP S1 "/NONAME/"
  701.       WRITE "; File transfer!"
  702.       WRITE "MESS `"Enter the file name: `"!"
  703.       WRITE "GET S1 60!"
  704.       ENDIF
  705.    GOTO Output             ; LOG the file name too
  706. ;
  707. ; ----- Subroutine:  Upload current file
  708. ;
  709. DownLoad:
  710.    GOSUB Ask_Method
  711.    S1 = "/NONAME/"              ; Make file name null
  712.    SWITCH S0
  713.       CASE "_NULL"              ; No entry
  714.     GOTO Main        ; No action
  715.       ENDCASE            ; .. no action
  716.       CASE "0"                  ; ZMODEM
  717.      S0 = "GETFILE ZMODEM S1"
  718.       ENDCASE
  719.       CASE "1"                  ; WXMODEM
  720.      GOSUB Ask_Name     ; Ask for fname in S1
  721.      S0 = "GETFILE WXMODEM S1"
  722.       ENDCASE
  723.       CASE "2"                  ; XMODEM
  724.      GOSUB Ask_Name     ; Ask for fname in S1
  725.      S0 = "GETFILE XMODEM S1"
  726.       ENDCASE
  727.       CASE "3"                  ; ASCII
  728.      GOSUB Ask_Name     ; Ask for fname in S1
  729.      S0 = "GETFILE ASCII S1"
  730.       ENDCASE
  731.       CASE "4"                  ; YMODEM/XMODEM1K
  732.      GOSUB Ask_Name     ; Ask for fname in S1
  733.      S0 = "GETFILE YMODEM S1"
  734.       ENDCASE
  735.       CASE "5"                  ; CISB
  736.      S0 = "GETFILE CISB"
  737.       ENDCASE
  738.       CASE "6"                  ; QuickB
  739.      S0 = "GETFILE QuickB"
  740.       ENDCASE
  741.       CASE "7"                  ; KERMIT
  742.      S0 = "GETFILE KERMIT"
  743.       ENDCASE
  744.       CASE "8"                  ; Batch YMODEM
  745.      S0 = "GETFILE BYMODEM"
  746.       ENDCASE
  747.       CASE "9"                  ; Batch YMODEM-G
  748.      S0 = "GETFILE BYMOG"
  749.       ENDCASE
  750.       DEFAULT
  751.     SOUND 100,100
  752.     GOTO Main        ; No action
  753.       ENDCASE
  754.    ENDSWITCH
  755.    GOTO Transfer
  756. ;
  757. ; ----- Subroutine: Ask for the upload method
  758. ;    S0 returns the selected method # (1-9) or null
  759. ;    S12 returns the from file name
  760. ;
  761. Ask_Method:
  762.    WOPEN  2 20 14 60 (contrast) ASK_ESC
  763.    ATSAY  2 22 (contrast) " Learn UpLoad/Download "
  764.    ATSAY  3 22 (contrast) " 1) Windowed XMODEM"
  765.    ATSAY  4 22 (contrast) " 2) CRC/Checksum XMODEM"
  766.    ATSAY  5 22 (contrast) " 3) ASCII transfer "
  767.    ATSAY  6 22 (contrast) " 4) YMODEM/XMODEM-1K"
  768.    ATSAY  7 22 (contrast) " 5) CIS-B          "
  769.    ATSAY  8 22 (contrast) " 6) CIS Quick-B    "
  770.    ATSAY  9 22 (contrast) " 7) Kermit         "
  771.    ATSAY 10 22 (contrast) " 8) Batch YMODEM   "
  772.    ATSAY 11 22 (contrast) " 9) Batch YMODEM-G "
  773.    ATSAY 11 22 (contrast) " 0) ZMODEM "
  774.    ATSAY 12 20 (contrast)  "├───────────────────────────────────────┤"
  775.    ATSAY 13 22 (contrast) "Enter method #:"
  776.    ATSAY 14 30 (contrast) " Press ESC to cancel "
  777.  
  778.    ATGET 13 48 (contrast) 1 S0 ; Read new method
  779.    WCLOSE
  780.    RETURN            ; And done
  781. ;
  782. ; ----- Subroutine: Ask for a up/down file name
  783. ;    SUCCESS returns fact script file successfully opened
  784. ;    S1 returns the fname
  785. ;
  786. Ask_Name:
  787.    WOPEN 10 10 13 70 (contrast) NAMEESC
  788.    ATSAY 10 12 (contrast) " Learn Up/Down Filename "
  789.    ATSAY 11 12 (contrast) "Enter a file name to be transferred:"
  790.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  791.  
  792.    ATGET 12 12 (contrast) 54 S1; Read new fname
  793.    WCLOSE
  794.    ;
  795.    ;       Attempt to execute the entry
  796.    ;
  797.    LJ S1            ; Left justify
  798.    S1 = S1&""                   ; Trim spaces
  799.    RETURN            ; And done
  800.    ;
  801.    ;       Escape during this...
  802.    ;
  803. NAMEESC:
  804.    S1 = ""
  805.    RETURN
  806. ;
  807. ;    Dial a number
  808. ;
  809. Dial:
  810.    GOSUB Ask_Dial        ; Get dial dir #
  811.    IF NOT SUCCESS or NULL S2 GOTO Main     ; IF ESC'd out
  812.    IF FIND S2 "m"
  813.       GOSUB Ask_number        ; Ask # to dial
  814.       IF FAILED or NULL S1 GOTO Main
  815.       MDIAL S1            ; Try to dial #
  816.    ELSE
  817.       DIAL S2            ; Try to dial #
  818.       ENDIF
  819.    IF FAILED GOTO Main
  820.    ;
  821.    ;    Write a DIAL paragraph to the output file
  822.    ;
  823.    WRITE "; Dialing!"
  824.    IF FIND S2 "m"               ; If manual...
  825.       WRITE "MDIAL `""
  826.       WRITE S1
  827.       WRITE "`"!"
  828.       WRITE "IF FAILED EXIT!"
  829.    ELSE             ; Else from directory
  830.       WRITE "IF NOT LINKED!"
  831.       WRITE "   DIAL `""
  832.       WRITE S2
  833.       WRITE "`"!"
  834.       WRITE "   IF FAILED EXIT!"
  835.       WRITE "   ENDIF!"
  836.       ENDIF
  837.    GOTO Main             ; LOG the file name too
  838. ;
  839. ; ----- Subroutine: Ask for a manually dialed #
  840. ;    SUCCESS returns fact script file successfully opened
  841. ;    S3 returns the fname
  842. ;
  843. Ask_Number:
  844.    WOPEN 10 10 13 70 (contrast) NAMEESC
  845.    ATSAY 10 12 (contrast) " Learn Manual Dial "
  846.    ATSAY 11 12 (contrast) "Enter the number to dial:"
  847.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  848.  
  849.    ATGET 12 12 (contrast) 14 S1; Read number
  850.    WCLOSE
  851.    ;
  852.    ;       Attempt to execute the entry
  853.    ;
  854.    LJ S1            ; Left justify
  855.    S1 = S1&""                   ; Trim spaces
  856.    RETURN            ; And done
  857. ;
  858. ; ----- Subroutine: Ask for the number to dial
  859. ;    S2 returns the selected entry # or null
  860. ;
  861. Ask_Dial:
  862.    N0 = 0            ; Page #
  863.    WOPEN  2 20 15 60 (contrast) ASK_ESC
  864.    ATSAY  2 22 (contrast) " Learn Dial  "
  865.    ATSAY 13 20 (contrast)  "├───────────────────────────────────────┤"
  866.    ATSAY 14 22 (contrast) "Entry# (or m):"
  867.    ATSAY 15 30 (contrast) " Press ESC to cancel "
  868.    ;
  869.    ;    Display the current page
  870.    ;
  871. Dial_Loop:
  872.    SCROLL 0,  3,22 12,58 (contrast) ; Clear display area
  873.    FOR N1 = 1,10
  874.        N4 = N0+N1
  875.        DIRECTORY S0 N4
  876.        ATSAY (2+N1) 22 (contrast) N4*")"
  877.        ATSAY (2+N1) 27 (contrast) S0
  878.        ENDFOR
  879.    LOCATE 14 37
  880.    N2 = 37            ; Currnt cursor
  881.    S2 = ""                      ; Clear save buffer
  882.    ;
  883.    ;    Wait for a keypress
  884.    ;
  885. Dial_Key:
  886.    KEYGET S0            ; Read keypress
  887.    LENGTH S0 N1
  888.    SWITCH N1            ; Switch on length
  889.       CASE 1            ; Len = 1: ASCII char
  890.      IF FIND S0 "m"         ; Manual dialing
  891.         S2 = S0        ; Set string
  892.         SET SUCCESS ON    ; Report success
  893.         GOTO Dial_End    ; .. and get out
  894.         ENDIF
  895.      IF NOT FIND "+-@#0123456789" S0
  896.         SOUND 100,100
  897.         GOTO Dial_Key
  898.         ENDIF
  899.      S2 = S2*S0        ; Save the keypress
  900.      ATSAY 14 N2 (contrast) S0
  901.      INC N2         ; Increment cursor
  902.      LOCATE 14 N2
  903.      GOTO Dial_Key
  904.       ENDCASE
  905.       CASE 2            ; Len = 2: ctl char
  906.      SWITCH S0        ; Handle individual ctl chars
  907.         CASE "0D"           ; Carriage rtn
  908.            SET SUCCESS ON
  909.            GOTO DIAL_End
  910.         ENDCASE
  911.         CASE "08"           ; Carriage rtn
  912.            LENGTH S2 N0
  913.            IF GT N0 1
  914.           S2 = S2(0:N0-2)
  915.           DEC N2    ; Increment cursor
  916.           LOCATE 14 N2
  917.           ATSAY 14 N2 (contrast) " "
  918.            ELSE
  919.           S2 = ""       ; Clear field so far
  920.           N2 = 37
  921.           ATSAY 14 N2 (contrast) " "
  922.           ENDIF
  923.            GOTO Dial_Key
  924.         ENDCASE
  925.         DEFAULT        ; Any other ctl char
  926.            SOUND 100,100
  927.            GOTO Dial_Key
  928.         ENDCASE
  929.      ENDSWITCH
  930.       ENDCASE            ; End len = 2
  931.       CASE 4
  932.      SWITCH S0        ; Len = 4: Ftn key
  933.         CASE "4900"         ; PgUp
  934.           N0 = N0-10
  935.           IF LT N0 0
  936.          N0 = 90
  937.          ENDIF
  938.           GOTO Dial_Loop
  939.         ENDCASE
  940.         CASE "5100"         ; PgDn
  941.           N0 = N0+10
  942.           IF GE N0 100
  943.          N0 = 0
  944.          ENDIF
  945.           GOTO Dial_Loop
  946.         ENDCASE
  947.         CASE "4700"         ; Home
  948.           N0 = 0
  949.           GOTO Dial_Loop
  950.         ENDCASE
  951.         CASE "4F00"         ; End
  952.           N0 = 90
  953.           GOTO Dial_Loop
  954.         ENDCASE
  955.         DEFAULT        ; Any other ftn keyr
  956.            SOUND 100,100
  957.            GOTO Dial_Key
  958.         ENDCASE
  959.      ENDSWITCH
  960.       ENDCASE
  961.       DEFAULT            ; Len <> 1,2,4... e.g. esc
  962.      SET SUCCESS OFF
  963.       ENDCASE
  964.    ENDSWITCH
  965. Dial_End:
  966.    WCLOSE
  967.    RETURN            ; And done
  968. ;
  969. ;    Load an accessory
  970. ;
  971. Accessry:
  972.    GOSUB Ask_AccNum        ; Get acc dir #
  973.    IF NOT SUCCESS or NULL S2 GOTO Main    ; IF ESC'd out
  974.    S0 = "WARNING: An accessory ends LEARN.  Enter Y to proceed."
  975.    GOSUB Ask_YN
  976.    IF NOT SUCCESS GOTO Main    ; IF ESC'd out
  977.    ;
  978.    ;    Write an ACC paragraph to the output file
  979.    ;
  980.    WRITE "; Accessory!"
  981.    WRITE "ACCESSORY `""
  982.    LENGTH S2 N2
  983.    WRITE S2 N2
  984.    WRITE "`"!"
  985.    GOSUB End_Learn        ; Terminate output
  986.    ;
  987.    ;    And execute the accessory
  988.    ;
  989.    ACCESSORY S2         ; Load accessory
  990. Dummy1:
  991.    GOTO Main            ; Branch if EXECUTE fails
  992. ;
  993. ; ----- Subroutine: Ask for the entry number to execute
  994. ;    S2 returns the selected entry # or null
  995. ;
  996. Ask_AccNum:
  997.    N0 = 0            ; Page #
  998.    WOPEN  2 10 15 70 (contrast) ASK_ESC
  999.    ATSAY  2 12 (contrast) " Learn Accessory "
  1000.    ATSAY 13 10 (contrast)  "├───────────────────────────────────────────────────────────┤"
  1001.    ATSAY 14 12 (contrast) "Enter entry #:"
  1002.    ATSAY 15 20 (contrast) " Press ESC to cancel "
  1003.    ;
  1004.    ;    Display the current page
  1005.    ;
  1006. Acc_Loop:
  1007.    SCROLL 0,  3,12 12,68 (contrast) ; Clear display area
  1008.    FOR N1 = 1,10
  1009.        N4 = N0+N1
  1010.        ANAME S0 N4
  1011.        ATSAY (2+N1) 12 (contrast) N4*")"
  1012.        ATSAY (2+N1) 17 (contrast) S0
  1013.        ENDFOR
  1014.    LOCATE 14 27
  1015.    N2 = 27            ; Currnt cursor
  1016.    S2 = ""                      ; Clear save buffer
  1017.    ;
  1018.    ;    Wait for a keypress
  1019.    ;
  1020. Acc_Key:
  1021.    KEYGET S0            ; Read keypress
  1022.    LENGTH S0 N1
  1023.    SWITCH N1            ; Switch on length
  1024.       CASE 1            ; Len = 1: ASCII char
  1025.      IF NOT FIND "0123456789" S0
  1026.         SOUND 100,100
  1027.         GOTO Acc_Key
  1028.         ENDIF
  1029.      S2 = S2*S0        ; Save the keypress
  1030.      ATSAY 14 N2 (contrast) S0
  1031.      INC N2         ; Increment cursor
  1032.      LOCATE 14 N2
  1033.      GOTO Acc_Key
  1034.       ENDCASE
  1035.       CASE 2            ; Len = 2: ctl char
  1036.      SWITCH S0        ; Handle individual ctl chars
  1037.         CASE "0D"           ; Carriage rtn
  1038.            SET SUCCESS ON
  1039.            GOTO Acc_End
  1040.         ENDCASE
  1041.         CASE "08"           ; Carriage rtn
  1042.            LENGTH S2 N0
  1043.            IF GT N0 1
  1044.           S2 = S2(0:N0-2)
  1045.           DEC N2    ; Increment cursor
  1046.           LOCATE 14 N2
  1047.           ATSAY 14 N2 (contrast) " "
  1048.            ELSE
  1049.           S2 = ""       ; Clear field so far
  1050.           N2 = 27
  1051.           ATSAY 14 N2 (contrast) " "
  1052.           ENDIF
  1053.            GOTO Acc_Key
  1054.         ENDCASE
  1055.         DEFAULT        ; Any other ctl char
  1056.            SOUND 100,100
  1057.            GOTO Acc_Key
  1058.         ENDCASE
  1059.      ENDSWITCH
  1060.       ENDCASE            ; End len = 2
  1061.       CASE 4
  1062.      SWITCH S0        ; Len = 4: Ftn key
  1063.         CASE "4900"         ; PgUp
  1064.           N0 = N0-10
  1065.           IF LT N0 0
  1066.          N0 = 40
  1067.          ENDIF
  1068.           GOTO Acc_Loop
  1069.         ENDCASE
  1070.         CASE "5100"         ; PgDn
  1071.           N0 = N0+10
  1072.           IF GE N0 50
  1073.          N0 = 0
  1074.          ENDIF
  1075.           GOTO Acc_Loop
  1076.         ENDCASE
  1077.         CASE "4700"         ; Home
  1078.           N0 = 0
  1079.           GOTO Acc_Loop
  1080.         ENDCASE
  1081.         CASE "4F00"         ; End
  1082.           N0 = 40
  1083.           GOTO Acc_Loop
  1084.         ENDCASE
  1085.         DEFAULT        ; Any other ftn keyr
  1086.            SOUND 100,100
  1087.            GOTO Acc_Key
  1088.         ENDCASE
  1089.      ENDSWITCH
  1090.       ENDCASE
  1091.       DEFAULT            ; Len <> 1,2,4... e.g. esc
  1092.      SET SUCCESS OFF
  1093.       ENDCASE
  1094.    ENDSWITCH
  1095. Acc_End:
  1096.    WCLOSE
  1097.    RETURN            ; And done
  1098. ;
  1099. ;    Load a script
  1100. ;
  1101. Script:
  1102.    S1 = "Enter the script file name:"
  1103.    GOSUB Ask_File        ; Get script file name
  1104.    IF NOT SUCCESS or NULL S0 GOTO Main     ; IF ESC'd out
  1105.    S2 = S0            ; Save fname
  1106.    IF NOT ISSCFILE S2        ; Test for presence
  1107.       S0 = "Script file not found: "*S2
  1108.       GOSUB Error
  1109.       GOTO Script
  1110.       ENDIF
  1111.    ;
  1112.    ;    Warn termination
  1113.    ;
  1114.    S0 = "WARNING: A script call ends LEARN.  Enter Y to proceed."
  1115.    GOSUB Ask_YN
  1116.    IF NOT SUCCESS GOTO Main    ; IF ESC'd out
  1117.    ;
  1118.    ;    Write a script paragraph to the output file
  1119.    ;
  1120.    WRITE "; Script!"
  1121.    WRITE "EXECUTE `""
  1122.    WRITE S2
  1123.    WRITE "`"!"
  1124.    GOSUB End_Learn        ; Terminate output
  1125.    ;
  1126.    ;    And execute the script
  1127.    ;
  1128.    EXECUTE S2            ; Load accessory
  1129. Dummy2:
  1130.    GOTO Main            ; Branch if EXECUTE fails
  1131. ;
  1132. ;    Change drive:subdir
  1133. ;
  1134. Chdir:
  1135.    S1 = "Enter the new drive:subdirectory:"
  1136.    GOSUB Ask_File        ; Get script file name
  1137.    IF NOT SUCCESS or NULL S0 GOTO Main     ; IF ESC'd out
  1138.    S0 = "CHDIR `""*S0&"`""
  1139.    PERFORM S0            ; Execute instruction in S0
  1140.    GOTO Output            ; Set-up the line to add to output
  1141. ;
  1142. ;    Change default dload drive:subdir
  1143. ;
  1144. DlDir:
  1145.    S1 = "Enter the new download drive:subdirectory:"
  1146.    GOSUB Ask_File        ; Get script file name
  1147.    IF NOT SUCCESS or NULL S0 GOTO Main     ; IF ESC'd out
  1148.    S0 = "SET DLDIR `""*S0&"`""
  1149.    PERFORM S0            ; Execute instruction in S0
  1150.    GOTO Output            ; Set-up the line to add to output
  1151. ;
  1152. ;    Toggle the log function
  1153. ;
  1154. Log:
  1155.    IF STRCMP "_LOGG" "OFF"
  1156.       S1 = "Enter the transcript file name:"
  1157.       GOSUB Ask_File        ; Get script file name
  1158.       IF NOT SUCCESS or NULL S0 GOTO Main; IF ESC'd out
  1159.       S0 = "LOG OPEN `""*S0&"`""
  1160.       SET FLAG(2) ON        ; Flag fact for exit
  1161.    ELSE
  1162.       IF NOT FLAG(2)        ; If was on when entered
  1163.      LOG CLOSE        ; Close the log
  1164.      GOTO Main        ; And don't add to output
  1165.      ENDIF
  1166.       S0 = "LOG CLOSE"
  1167.       ENDIF
  1168.    PERFORM S0            ; Execute instruction in S0
  1169.    GOSUB StatusLine        ; Update statusline
  1170.    GOTO Output            ; Set-up the line to add to output
  1171. ;
  1172. ;    Toggle the log hold function
  1173. ;
  1174. LogHold:
  1175.    IF STRCMP "_LOGG" "OFF" GOTO Main ; If not logging
  1176.    IF STRCMP "_LOGH" "OFF"
  1177.       S0 = "LOG SUSPEND"
  1178.    ELSE
  1179.       S0 = "LOG RESUME"
  1180.       ENDIF
  1181.    PERFORM S0            ; Execute instruction in S0
  1182.    GOSUB StatusLine        ; Update statusline
  1183.    GOTO Output            ; Set-up the line to add to output
  1184. ;
  1185. ;    Set comm parms
  1186. ;
  1187. Parms:
  1188.    S0 = ""                      ; Default target vars
  1189.    S1 = ""                      ; ..
  1190.    S2 = ""                      ; ..
  1191.    S3 = ""                      ; ..
  1192.    GOSUB Ask_Parms        ; Ask for a number
  1193.    LJ S0            ; Left justify response
  1194.    SWITCH S0            ; Switch on response in Get_parms
  1195.       CASE "_NULL"              ; No entry
  1196.      GOTO Main        ; No action
  1197.       ENDCASE            ; .. no action
  1198.       CASE "1"                  ;  300,e,7,1
  1199.      S0 = "SET BAUD 300"
  1200.      GOTO Even_7_1
  1201.       ENDCASE
  1202.       CASE "2"                  ; 1200,e,7,1
  1203.      S0 = "SET BAUD 1200"
  1204.      GOTO Even_7_1
  1205.       ENDCASE
  1206.       CASE "3"                  ; 2400,e,7,1
  1207.      S0 = "SET BAUD 2400"
  1208.      GOTO Even_7_1
  1209.       ENDCASE
  1210.       CASE "4"                  ; 4800,e,7,1
  1211.      S0 = "SET BAUD 4800"
  1212.      GOTO Even_7_1
  1213.       ENDCASE
  1214.       CASE "5"                  ; 9600,e,7,1
  1215.      S0 = "SET BAUD 9600"
  1216.      GOTO Even_7_1
  1217.       ENDCASE
  1218.       CASE "6"                  ; 19.2,e,7,1
  1219.      S0 = "SET BAUD 19K"
  1220.      GOTO Even_7_1
  1221.       ENDCASE
  1222.       CASE "7"                  ; 38.4,e,7,1
  1223.      S0 = "SET BAUD 38K"
  1224.      GOTO Even_7_1
  1225.       ENDCASE
  1226.       CASE "8"                  ; 57.6,e,7,1
  1227.      S0 = "SET BAUD 57K"
  1228.      GOTO Even_7_1
  1229.       ENDCASE
  1230.       CASE "9"                  ; 115K,e,7,1
  1231.      S0 = "SET BAUD 115K"
  1232.      GOTO Even_7_1
  1233.       ENDCASE
  1234.       CASE "10"                 ;  300,n,8,1
  1235.      S0 = "SET BAUD 300"
  1236.      GOTO None_8_1
  1237.       ENDCASE
  1238.       CASE "11"                 ; 1200,n,8,1
  1239.      S0 = "SET BAUD 1200"
  1240.      GOTO None_8_1
  1241.       ENDCASE
  1242.       CASE "12"                 ; 2400,n,8,1
  1243.      S0 = "SET BAUD 2400"
  1244.      GOTO None_8_1
  1245.       ENDCASE
  1246.       CASE "13"                 ; 4800,n,8,1
  1247.      S0 = "SET BAUD 4800"
  1248.      GOTO None_8_1
  1249.       ENDCASE
  1250.       CASE "14"                 ; 9600,n,8,1
  1251.      S0 = "SET BAUD 9600"
  1252.      GOTO None_8_1
  1253.       ENDCASE
  1254.       CASE "15"                 ; 19.2,n,8,1
  1255.      S0 = "SET BAUD 19K"
  1256.      GOTO None_8_1
  1257.       ENDCASE
  1258.       CASE "16"                 ; 38.4,n,8,1
  1259.      S0 = "SET BAUD 38k"
  1260.      GOTO None_8_1
  1261.       ENDCASE
  1262.       CASE "17"                 ; 57.6,n,8,1
  1263.      S0 = "SET BAUD 57k"
  1264.      GOTO None_8_1
  1265.       ENDCASE
  1266.       CASE "18"                 ; 115K,n,8,1
  1267.      S0 = "SET BAUD 115K"
  1268.      GOTO None_8_1
  1269.       ENDCASE
  1270.       CASE "19"                 ; Even parity
  1271.      S0 = "SET PARITY EVEN"
  1272.       ENDCASE
  1273.       CASE "20"                 ; Odd parity
  1274.      S0 = "SET PARITY ODD"
  1275.       ENDCASE
  1276.       CASE "21"                 ; No parity
  1277.      S0 = "SET PARITY ODD"
  1278.       ENDCASE
  1279.       CASE "22"                 ; 7 data
  1280.      S0 = "SET DATA 7"
  1281.       ENDCASE
  1282.       CASE "23"                 ; 8 data
  1283.      S0 = "SET DATA 8"
  1284.       ENDCASE
  1285.       CASE "24"                 ; 1 stop bits
  1286.      S0 = "SET STOP 1"
  1287.       ENDCASE
  1288.       CASE "25"                 ; 2 stop bits
  1289.      S0 = "SET STOP 2"
  1290.       ENDCASE
  1291.       CASE "26"                 ; COM1
  1292.      S0 = "SET PORT COM1"
  1293.       ENDCASE
  1294.       CASE "27"                 ; COM2
  1295.      S0 = "SET PORT COM2"
  1296.       ENDCASE
  1297.       CASE "28"                 ; COM3
  1298.      S0 = "SET PORT COM3"
  1299.       ENDCASE
  1300.       CASE "29"                 ; COM4
  1301.      S0 = "SET PORT COM4"
  1302.       ENDCASE
  1303.       DEFAULT
  1304.     SOUND 100,100
  1305.     GOTO Parms        ; Repeat request
  1306.       ENDCASE
  1307.    ENDSWITCH
  1308.    GOTO End_Parms
  1309.    ;
  1310.    ;    Set EVEN,7,1 in addition to S0 already set
  1311.    ;
  1312. Even_7_1:
  1313.    S1 = "SET PARITY EVEN"        ; Set-up alternate vars
  1314.    S2 = "SET DATA 7"
  1315.    S3 = "SET STOP 1"
  1316.    GOTO End_Parms
  1317.    ;
  1318.    ;    Set NONE,8,1 too
  1319.    ;
  1320. None_8_1:
  1321.    S1 = "SET PARITY NONE"        ; Set-up alternate vars
  1322.    S2 = "SET DATA 8"
  1323.    S3 = "SET STOP 1"
  1324.    ;
  1325.    ;    Execute the command and write to script
  1326.    ;
  1327. End_Parms:
  1328.    IF NOT NULL S0
  1329.       PERFORM S0        ; Execute
  1330.       WRITE S0*"!"              ; Write to log file
  1331.       ENDIF
  1332.    IF NOT NULL S1
  1333.       PERFORM S1        ; Execute
  1334.       WRITE S1*"!"              ; Write to log file
  1335.       ENDIF
  1336.    IF NOT NULL S2
  1337.       PERFORM S2        ; Execute
  1338.       WRITE S2*"!"              ; Write to log file
  1339.       ENDIF
  1340.    IF NOT NULL S3
  1341.       PERFORM S3        ; Execute
  1342.       WRITE S3*"!"              ; Write to log file
  1343.       ENDIF
  1344.    GOTO Main            ; And we're done
  1345. ;
  1346. ; ----- Subroutine: Ask for the parameter selection
  1347. ;    S0 returns the selected method # (1-9) or null
  1348. ;
  1349. Ask_Parms:
  1350.    WOPEN  2 10 16 70 (contrast) ASK_ESC
  1351.    ATSAY  2 12 (contrast) " Learn Parms "
  1352.    ATSAY  3 12 (contrast) " 1)  300,E,7,1"
  1353.    ATSAY  4 12 (contrast) " 2) 1200,E,7,1"
  1354.    ATSAY  5 12 (contrast) " 3) 2400,E,7,1"
  1355.    ATSAY  6 12 (contrast) " 4) 4800,E,7,1"
  1356.    ATSAY  7 12 (contrast) " 5) 9600,E,7,1"
  1357.    ATSAY  8 12 (contrast) " 6) 19.2,E,7,1"
  1358.    ATSAY  9 12 (contrast) " 7) 38.4,E,7,1"
  1359.    ATSAY 10 12 (contrast) " 8) 57.6,E,7,1"
  1360.    ATSAY 11 12 (contrast) " 9) 115K,E,7,1"
  1361.  
  1362.    ATSAY  3 28 (contrast) "10)  300,N,8,1"
  1363.    ATSAY  4 28 (contrast) "11) 1200,N,8,1"
  1364.    ATSAY  5 28 (contrast) "12) 2400,N,8,1"
  1365.    ATSAY  6 28 (contrast) "13) 4800,N,8,1"
  1366.    ATSAY  7 28 (contrast) "14) 9600,N,8,1"
  1367.    ATSAY  8 28 (contrast) "15) 19.2,N,8,1"
  1368.    ATSAY  9 28 (contrast) "16) 38.4,N,8,1"
  1369.    ATSAY 10 28 (contrast) "16) 57.6,N,8,1"
  1370.    ATSAY 11 28 (contrast) "18) 115K,N,8,1"
  1371.  
  1372.    ATSAY  3 44 (contrast) "19) Even par."
  1373.    ATSAY  4 44 (contrast) "20) Odd parity"
  1374.    ATSAY  5 44 (contrast) "21) No parity"
  1375.  
  1376.    ATSAY  7 44 (contrast) "22) 7 data bits"
  1377.    ATSAY  8 44 (contrast) "23) 8 data bits"
  1378.  
  1379.    ATSAY 10 44 (contrast) "24) 1 stop bit"
  1380.    ATSAY 11 44 (contrast) "25) 2 stop bits"
  1381.  
  1382.    ATSAY  3 60 (contrast) "26) COM1"
  1383.    ATSAY  4 60 (contrast) "27) COM2"
  1384.    ATSAY  5 60 (contrast) "28) COM3"
  1385.    ATSAY  6 60 (contrast) "29) COM4"
  1386.  
  1387.    ATSAY 12 10 (contrast)  "├───────────────────────────────────────────────────────────┤"
  1388.    COMPARMS S0
  1389.    ATSAY 13,12 (contrast) "Current setting: "*S0
  1390.    ATSAY 14 10 (contrast)  "├───────────────────────────────────────────────────────────┤"
  1391.    ATSAY 15 12 (contrast) "Enter selection #:"
  1392.    ATSAY 16 30 (contrast) " Press ESC to cancel "
  1393.  
  1394.    ATGET 15 31 (contrast) 2 S0 ; Read selection
  1395.    WCLOSE
  1396.    RETURN            ; And done
  1397. ;
  1398. ;    Encrypt/decrypt
  1399. ;
  1400. Encrypt:
  1401.    GOSUB Ask_Encrypt        ; Ask for a number
  1402.    SWITCH S0            ; Switch on response in Get_parms
  1403.       CASE "_NULL"              ; No entry
  1404.      GOTO Main        ; No action
  1405.       ENDCASE            ; .. no action
  1406.       CASE "1"                  ; Simple encrypt
  1407.      S2 = "ENCRYPT"
  1408.      S3 = "SIMPLE"
  1409.       ENDCASE
  1410.       CASE "2"                  ; Decrypt
  1411.      S2 = "DECRYPT"
  1412.      S3 = ""                ; No operand
  1413.       ENDCASE
  1414.       DEFAULT
  1415.     SOUND 100,100
  1416.     GOTO Encrypt        ; Repeat request
  1417.       ENDCASE
  1418.    ENDSWITCH
  1419.    ;
  1420.    ;    Ask for the source file
  1421.    ;
  1422. EncrSrc:
  1423.    S1 = "Enter the file to be encrypted/decrypted:"
  1424.    GOSUB Ask_File
  1425.    IF NOT SUCCESS or NULL S0 GOTO Main    ; IF ESC'd out
  1426.    IF NOT ISFILE S0        ; IF file doesn't exist
  1427.       S0 = "File does not exist: "*S0
  1428.       GOSUB Error
  1429.       GOTO EncrSrc
  1430.       ENDIF
  1431.    S4 = S0            ; Save fname
  1432.    ;
  1433.    ;    Ask for the destination file
  1434.    ;
  1435. EncrDest:
  1436.    S1 = "Name the output of encryption/decryption:"
  1437.    GOSUB Ask_File
  1438.    IF NOT SUCCESS or NULL S0 GOTO Main     ; IF ESC'd out
  1439.    IF ISFILE S0         ; IF file doesn't exist
  1440.       S0 = "File exists: "*S0&".  Delete it Y/N?"
  1441.       GOSUB Ask_YN
  1442.       IF SUCCESS
  1443.      DELETE S0
  1444.       ELSE
  1445.      GOTO EncrSrc
  1446.      ENDIF
  1447.       ENDIF
  1448.    S5 = S0            ; Save fname
  1449.    ;
  1450.    ;    Ask for the password
  1451.    ;
  1452. EncrPsw:
  1453.    S1 = "Enter the password:"
  1454.    GOSUB Ask_File
  1455.    IF NOT SUCCESS or NULL S0 GOTO Main     ; IF ESC'd out
  1456.    S6 = S0            ; Save fname
  1457.    ;
  1458.    ;    Execute the command and write to script
  1459.    ;
  1460.    S0 = S2&" S4 S5 S6 "*S3
  1461.    PERFORM S0            ; Execute
  1462.    IF NOT SUCCESS        ; If it failed
  1463.       S0 = "Encrypt/decrypt failed.  Nothing logged to script."
  1464.       GOSUB Error
  1465.       Goto Main
  1466.       ENDIF
  1467.    ;
  1468.    ;    Log an encrypt/decrypt sequence
  1469.    ;
  1470.    WRITE "; Encrypt/decrypt!"
  1471.    WRITE "MESS `"Enter the encrypt/decrypt source: `"!"
  1472.    WRITE "GET S1 60!"
  1473.    WRITE "MESS `"Enter the encrypt/decrypt destination: `"!"
  1474.    WRITE "GET S2 60!"
  1475.    WRITE "MESS `"Enter the encrypt/decrypt password: `"!"
  1476.    WRITE "GET S3 60!"
  1477.    WRITE S2&" S1 S2 S3 "*S3*"!"
  1478.    GOTO Main            ; And we're done
  1479. ;
  1480. ; ----- Subroutine: Ask for the parameter selection
  1481. ;    S0 returns the selected method # (1-9) or null
  1482. ;
  1483. Ask_Encrypt:
  1484.    WOPEN  2 20 8  60 (contrast) ASK_ESC
  1485.    ATSAY  2 22 (contrast) " Learn D/Encrypt "
  1486.    ATSAY  4 22 (contrast) " 1) Simple encryption"
  1487.    ATSAY  5 22 (contrast) " 2) Decrypt encrypted file"
  1488.  
  1489.    ATSAY  6 20 (contrast)  "├───────────────────────────────────────┤"
  1490.    ATSAY  7 22 (contrast) "Enter selection #:"
  1491.    ATSAY  8 30 (contrast) " Press ESC to cancel "
  1492.  
  1493.    ATGET  7 41 (contrast) 1 S0    ; Read selection
  1494.    WCLOSE
  1495.    RETURN            ; And done
  1496. ;
  1497. ;    Toggle the blank line eater
  1498. ;
  1499. Blnkln:
  1500.    S0 = "SET BSUPPRESS ON"      ; Default as if off
  1501.    IF STRCMP "_BSUP" "ON "      ; Test current setting
  1502.       S0 = "SET BSUPPRESS OFF"  ; Set-up cmd
  1503.       ENDIF
  1504.    PERFORM S0            ; Execute instruction in S0
  1505.    GOSUB StatusLine        ; Update status line
  1506.    GOTO Output            ; And write to output file
  1507. ;
  1508. ;    Toggle the CR/CRLF function (on received CRs)
  1509. ;
  1510. CRLF:
  1511.    S0 = "SET CR CR_LF"          ; Default as if off
  1512.    IF STRCMP "_CRLF" "ON "      ; Test current setting
  1513.       S0 = "SET CR CR"          ; Set-up cmd
  1514.       ENDIF
  1515.    PERFORM S0            ; Execute instruction in S0
  1516.    GOSUB StatusLine        ; Update status line
  1517.    GOTO Output            ; And write to output file
  1518. ;
  1519. ; ----- Subroutine: Draw the basic screen box
  1520. ;
  1521. Screen:
  1522.    DWINDOW CLEAR        ; Clear any window setting
  1523.    CLEAR (default)        ; Clear whole window
  1524.    SSIZE N99            ; Get current screen size
  1525.    DWINDOW N99-12,2 N99-12 77    ; Set kbd scrolling region
  1526.    BOX     N99-13,  0,(N99-11),79 (default)
  1527.  
  1528.    ATSAY 0,0 (default)    ">>───────────────────────────────────────────────────────────────────────────<<"
  1529.    ATSAY 0,      3  (default) " Learn "
  1530.    ATSAY (N99-13),3  (default) " Keyboard "
  1531.    ATSAY N99-11, 28  (default) " ESC to terminate "
  1532.    ATSAY N99-11, 53  (default) " Press F10 for info "
  1533.  
  1534.    ATSAY N99-10,2  (default) "F1 Load accessory         Alt-Q Toggle CR/CRLF      Alt-P   Set comm parms"
  1535.    ATSAY N99- 9,2  (default) "F2 Execute script         Alt-E Toggle echo         Alt-G   Toggle blnkln "
  1536.    ATSAY N99- 8,2  (Default) "F3 Change drive:subdir    Alt-C Clear screen        PgUp    Upload        "
  1537.    ATSAY N99- 7,2  (Default) "F4 Set dft dlo subdir     Alt-L Toggle 25/43        PgDn    Download      "
  1538.    ATSAY N99- 6,2  (Default) "F5 Toggle line/char       Alt-H Hangup              Alt-F10 Shell to DOS  "
  1539.    ATSAY N99- 5,2  (Default) "F6 Toggle learn hold      Alt-D Dial                Alt-0/9 Send macro    "
  1540.    ATSAY N99- 4,2  (Default) "F7 Toggle logging file    Alt-N Encrypt/decrypt     Ctl-End Send break    "
  1541.    ATSAY N99- 3,2  (Default) "F9 Toggle log hold        Alt-Z Toggle masking      Ctl-Prt Toggle print  "
  1542.    SCROLL 0,N99-2,0 N99-2,79 "_BAR"
  1543.    GOSUB StatusLine
  1544.    ;
  1545.    ;    Set cursor positions, and we're done
  1546.    ;
  1547.    N95 = 1            ; Receive area row
  1548.    N96 = 0            ; Receive area col
  1549.    N93 = N99-12         ; Kbd area row
  1550.    N94 = 2            ; Kbd area col
  1551.  
  1552.    RETURN
  1553. ;
  1554. ; -----Subroutine: Update the status line
  1555. ;
  1556. StatusLine:
  1557.    IF STRCMP "_DUPL" "HALF"
  1558.       ATSAY N99-2,2  "_bar" "Echo"
  1559.    ELSE
  1560.       ATSAY N99-2,2  "_bar" "    "
  1561.       ENDIF
  1562.  
  1563.    IF STRCMP "_MASK" "ON"
  1564.       ATSAY N99-2,8  "_bar" "Mask"
  1565.    ELSE
  1566.       ATSAY N99-2,8  "_bar" "    "
  1567.       ENDIF
  1568.  
  1569.    IF STRCMP "_BSUP" "ON "
  1570.       ATSAY N99-2,14 "_bar" "NoBln"
  1571.    ELSE
  1572.       ATSAY N99-2,14 "_bar" "     "
  1573.       ENDIF
  1574.  
  1575.    IF STRCMP "_CRLF" "ON "
  1576.       ATSAY N99-2,21 "_bar" "CR_LF"
  1577.    ELSE
  1578.       ATSAY N99-2,21 "_bar" "     "
  1579.       ENDIF
  1580.  
  1581.    IF STRCMP "_LOGG" "ON "
  1582.       ATSAY N99-2,28 "_bar"    "Logging"
  1583.       IF STRCMP "_LOGH" "ON"
  1584.      ATSAY N99-2,37 "_bar" "Log held"
  1585.       ELSE
  1586.      ATSAY N99-2,37 "_bar" "        "
  1587.      ENDIF
  1588.    ELSE
  1589.       ATSAY N99-2,28 "_bar"    "       "
  1590.       ATSAY N99-2,37 "_bar"    "        "
  1591.       ENDIF
  1592.  
  1593.    IF FLAG(1)
  1594.       ATSAY N99-2,47 "_bar" "Print"
  1595.    ELSE
  1596.       ATSAY N99-2,47 "_bar" "     "
  1597.       ENDIF
  1598.  
  1599.    IF FLAG(9)
  1600.       ATSAY N99-2,60 "_bar" "CharMode"
  1601.    ELSE
  1602.       ATSAY N99-2,60 "_bar" "LineMode"
  1603.       ENDIF
  1604.  
  1605.    IF FLAG(8)
  1606.       ATSAY N99-2,70 "_bar" "LearnHeld"
  1607.    ELSE
  1608.       ATSAY N99-2,70 "_bar" "         "
  1609.       ENDIF
  1610.    RETURN            ; And we're done
  1611. ;
  1612. ; ----- Subroutine: Help
  1613. ;
  1614. Help:
  1615.    WOPEN  0, 0,23,79 (default) HELPESC
  1616.    ATSAY  0, 2 (Default) " Learn Help "
  1617.    ATSAY 23,28 (Default) " Press any key to continue "
  1618. ;
  1619. ;    Help message
  1620. ;
  1621.    ATSAY  1,2 (default) "   The LEARN script creates a script based upon the actions taken.  The"
  1622.    ATSAY  2,2 (default) "function keys that LEARN will recognize and act upon are listed on the main"
  1623.    ATSAY  3,2 (default) "screen.  Each function results in an addition to the script being created,"
  1624.    ATSAY  4,2 (default) "with the exception of Alt-F10 (which allows editing of the script while it"
  1625.    ATSAY  5,2 (default) "is being created... it does not add a SHELL command to the script)."
  1626.    ATSAY  6,2 (default) ""
  1627.    ATSAY  7,2 (default) "   Initially LEARN is in 'line mode'.  When characters (a-z, 1-9) are typed,"
  1628.    ATSAY  8,2 (default) "they echo in the keyboard box.  When RETURN is typed, the whole line is"
  1629.    ATSAY  9,2 (default) "transmitted, and the appropriate script line(s) are written.  The 'mode' may"
  1630.    ATSAY 10,2 (default) "be switched to 'character', where each keystroke is transmitted when it is"
  1631.    ATSAY 11,2 (default) "typed (and each keystroke generates a WAITFOR/TRANSMIT command)."
  1632.    ATSAY 12,2 (default) ""
  1633.    ATSAY 13,2 (default) "NOTE: The display doubles carets and exclamation points.  This is done to"
  1634.    ATSAY 14,2 (default) "allow the the keystroke to correctly transmitted.  Don't be surprised!!"
  1635.    ATSAY 15,2 (default) ""
  1636.    ATSAY 16,2 (default) "   The LEARN script may be put on HOLD with the F6 key.  When held, what"
  1637.    ATSAY 17,2 (default) "is typed is sent, no script is generated, and no functions are available."
  1638.    ATSAY 18,2 (default) ""
  1639.    ATSAY 19,2 (default) "   LEARN does not provide all the functionality of COM-AND.  The basic"
  1640.    ATSAY 20,2 (default) "set of functions required to go on-line are provided.  Additional settings"
  1641.    ATSAY 21,2 (default) "may be added to the output script.  Extensive editing of the output script"
  1642.    ATSAY 22,2 (default) "is recommended in any case."
  1643. ;
  1644. ;    Wait for a keypress, and return
  1645. ;
  1646.    KEYGET S0
  1647.    WCLOSE
  1648.    RETURN
  1649.    ;
  1650.    ;    ESCAPE during this screen
  1651.    ;
  1652. HELPESC:
  1653.    RETURN
  1654. ;
  1655. ; ----- Subroutine: Fatal error.  Open a window, and display a message
  1656. ;    S0 passes the error message(s)
  1657. ;
  1658. Error:
  1659.    WOPEN 10,10,12,70 (contrast) Err_Esc
  1660.    ATSAY 10,12 (contrast) " Learn Error "
  1661.    ATSAY 11,12 (contrast) S0(0:55); Max msg width 55 chars
  1662.    ATSAY 12,26 (contrast) " Press any key to continue "
  1663.    ;
  1664.    ;    Wait a keypress
  1665.    ;
  1666.    KEYGET S0               ; Wait for any key
  1667.    WCLOSE
  1668. Err_Esc:
  1669.    RETURN
  1670. ;
  1671. ; ----- Subroutine: Ask for a script file name
  1672. ;    S1 passes the prompt used
  1673. ;    SUCCESS returns fact script file successfully opened
  1674. ;    S0 returns the fname
  1675. ;
  1676. Ask_File:
  1677.    WOPEN 10 10 13 70 (contrast) ASK_ESC
  1678.    ATSAY 10 12 (contrast) " Learn Fname "
  1679.    ATSAY 11 12 (contrast) S1(0:56)
  1680.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  1681.  
  1682.    ATGET 12 12 (contrast) 54 S0; Read new fname
  1683.    WCLOSE
  1684.    ;
  1685.    ;       Attempt to execute the entry
  1686.    ;
  1687.    LJ S0            ; Left justify
  1688.    S0 = S0 &""                  ; Trim spaces
  1689.    UPPER S0            ; Make pretty
  1690.    IF NOT NULL S0        ; If nothing entered
  1691.       SET SUCCESS ON
  1692.    ELSE
  1693.       SET SUCCESS OFF
  1694.       ENDIF
  1695.    RETURN            ; And done
  1696. ;
  1697. ; ----- Escape during a subwindow
  1698. ;    .. S0 is returned null
  1699. ;
  1700. Ask_Esc:
  1701.    S0 = ""                      ; Make a null return
  1702.    RETURN
  1703. ;
  1704. ; ----- Subroutine: Ask a question and take a y/n answer
  1705. ;    S0 passes the text to be displayed
  1706. ;    SUCCESS returns fact of y/n
  1707. ;
  1708. Ask_YN:
  1709.    WOPEN 10 10 13 70 (contrast) ASK_ESC
  1710.    ATSAY 10 12 (contrast) " Learn Y/N "
  1711.    ATSAY 11 12 (contrast) S0(0:55)
  1712.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  1713.  
  1714.    ATGET 12 12 (contrast) 1 S0 ; Read y/n
  1715.    WCLOSE
  1716.    ;
  1717.    ;       Interperet the response
  1718.    ;
  1719.    IF NULL S0 or FIND S0 "Y"    ; If c/r yes
  1720.       SET SUCCESS ON
  1721.    ELSE
  1722.       SET SUCCESS OFF
  1723.       ENDIF
  1724.    RETURN            ; And done
  1725. ;
  1726. ; ----- Subroutine: Write a line (in S0) to the output file
  1727. ;
  1728. WriteLn:
  1729.    WRITE S0            ; Write to file
  1730.    WRITE "!" 1                  ; Add a crlf
  1731.    RETURN            ; And continue
  1732. ;
  1733. ; ----- Subroutine: Write initial settings out to the output file
  1734. ;
  1735. Initial:
  1736.    ;
  1737.    ;    Comments
  1738.    ;
  1739.    IF CONNECTED
  1740.       S0 = "; -------------------------------------------------------"
  1741.       GOSUB WriteLn
  1742.       S0 = "; WARNING: This script learned after connection was made " *"_Date"
  1743.       GOSUB WriteLn
  1744.       S0 = "; ------------------------------------------------------- "
  1745.       GOSUB WriteLn
  1746.       GOTO No_Init
  1747.       ENDIF
  1748.    ;
  1749.    ;    Save initial settings
  1750.    ;
  1751.    S0 = "; Initial state: "*"_Date"
  1752.    GOSUB WriteLn
  1753.    S0 = "SET DUPLEX "*"_DUPL"
  1754.    GOSUB WriteLn
  1755.    S0 = "EMULATE "*"_EMUL"
  1756.    GOSUB WriteLn
  1757.    S0 = "SET 25"
  1758.    IF GT "_SSIZ" 25
  1759.       S0 = "SET 43"
  1760.       ENDIF
  1761.    GOSUB WriteLn
  1762.    S0 = "SET MASK "*"_MASK"
  1763.    GOSUB WriteLn
  1764.    S0 = "SET CR CR_LF"
  1765.    IF STRCMP "_CRLF" "OFF"
  1766.       S0 = "SET CR CR"
  1767.       ENDIF
  1768.    GOSUB WriteLn
  1769.    ;
  1770.    ;    Save current comm parameters
  1771.    ;
  1772.    COMPARM S1
  1773.    S0 = "SET PORT "*S1(11:14)
  1774.    GOSUB WriteLn
  1775.    S0 = "SET BAUD "*S1(0:3)
  1776.    GOSUB WriteLn
  1777.    IF STRCMP S1(5:5) "E"
  1778.       S0 = "SET PARITY EVEN"
  1779.    ELSE
  1780.       IF STRCMP S1(5:5) "O"
  1781.      S0 = "SET PARITY ODD"
  1782.       ELSE
  1783.      S0 = "SET PARITY NONE"
  1784.      ENDIF
  1785.       ENDIF
  1786.    GOSUB WriteLn
  1787.    S0 = "SET DATA "*S1(7:7)
  1788.    GOSUB WriteLn
  1789.    S0 = "SET STOP "*S1(9:9)
  1790.    GOSUB WriteLn
  1791.    ;
  1792.    ;    Final comment to start learned portion
  1793.    ;    .. and a few settings that might be desired on/off line
  1794.    ;
  1795. No_Init:
  1796.    S0 = "; Learned script"
  1797.    GOSUB WriteLn
  1798.    S0 = "LEGEND `"Script learned: `"*`""*"_Date"*"`""
  1799.    GOSUB WriteLn
  1800.    IF FLAG(1)
  1801.       S0 = "PRINTER ON"
  1802.    ELSE
  1803.       S0 = "PRINTER OFF"
  1804.       ENDIF
  1805.    GOSUB WriteLn
  1806.    S0 = "SET CHAT "*"_CHAT"
  1807.    GOSUB WriteLn
  1808.    S0 = "SET KBDB "*"_KBDB"
  1809.    GOSUB WriteLn
  1810.    RETURN
  1811.